<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:51:"themes/admin_simpleboot3/mainiu\goods\goodsadd.html";i:1514894054;s:43:"themes/admin_simpleboot3/public\header.html";i:1514893354;}*/ ?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->

    <link href="__TMPL__/public/assets/themes/<?php echo cmf_get_admin_style(); ?>/bootstrap.min.css" rel="stylesheet">
    <link href="__TMPL__/public/assets/simpleboot3/css/simplebootadmin.css" rel="stylesheet">
    <link href="__STATIC__/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <style>
        form .input-order {
            margin-bottom: 0px;
            padding: 0 2px;
            width: 42px;
            font-size: 12px;
        }

        form .input-order:focus {
            outline: none;
        }

        .table-actions {
            margin-top: 5px;
            margin-bottom: 5px;
            padding: 0px;
        }

        .table-list {
            margin-bottom: 0px;
        }

        .form-required {
            color: red;
        }
    </style>
    <script type="text/javascript">
        //全局变量
        var GV = {
            ROOT: "__ROOT__/",
            WEB_ROOT: "__WEB_ROOT__/",
            JS_ROOT: "static/js/",
            APP: '<?php echo \think\Request::instance()->module(); ?>'/*当前应用名*/
        };
    </script>
    <script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <script src="__STATIC__/js/wind.js"></script>
    <script src="__TMPL__/public/assets/js/bootstrap.min.js"></script>
    <script>
        Wind.css('artDialog');
        Wind.css('layer');
        $(function () {
            $("[data-toggle='tooltip']").tooltip();
            $("li.dropdown").hover(function () {
                $(this).addClass("open");
            }, function () {
                $(this).removeClass("open");
            });
        });
    </script>
    <?php if(APP_DEBUG): ?>
        <style>
            #think_page_trace_open {
                z-index: 9999;
            }
        </style>
    <?php endif; ?>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="<?php echo url('Goods/goodsadd'); ?>">添加商品</a></li>
    </ul>
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered frrom">
                    <tr>
                        <th width="100">分类<span class="form-required">*</span></th>
                        <td>
                            <select style="width: 30%;height: 2em;" name="" id="cate">
                                <?php if(is_array($data) || $data instanceof \think\Collection || $data instanceof \think\Paginator): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo['id']; ?>"><?php echo $vo['name']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>名称<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control name" type="text" name="post[post_title]"
                                   id="title" required value="" placeholder="请输入标题"/>
                        </td>
                    </tr>
                    <tr>
                        <th>价格<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control price" type="number" name="post[post_title]"
                                   id="price" required value="0" placeholder="请输入价格"/>
                        </td>
                    </tr>
                    <tr>
                        <th>销量<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="number" name="post[post_title]"
                                   id="sales" required value="0" placeholder="请输入销量"/>
                        </td>
                    </tr>
                    <tr>
                        <th><b>封面图</b><span class="form-required">*</span></th>
                        <td>
                            <div style="text-align: center;">
                                <input type="hidden" class="thumbb" name="post[more][thumbnail]" id="thumbnail" value="">
                                <a href="javascript:uploadOneImagea('图片上传','#thumbnail');">
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                         id="thumbnail-preview"
                                         width="135" style="cursor: pointer"/>
                                </a>
                                <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
                            </div>
                        </td>
                    </tr>
                    <script>
                        function uploadOneImagea(dialog_title, input_selector, extra_params, app) {
                            openUploadDialog(dialog_title, function (dialog, files) {
                                $(input_selector).val(files[0].preview_url);
                                $(input_selector + '-preview').attr('src', files[0].preview_url);
                                $(input_selector + '-name').val(files[0].name);
                            }, extra_params, 0, 'image', app);
                        }
                    </script>
                    <tr>
                        <th>详细介绍</th>
                        <td>
                            <script type="text/plain" id="content" name="post[post_content]"></script>
                        </td>
                    </tr>
                    <tr>
                        <th><b>状态</b></th>
                        <td>
                            <div class="checkbox">
                                <label><input class="checkk" type="checkbox" name="post[post_status]" value="1">推荐</label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th><b>添加时间</b></th>
                        <td>
                            <input class="form-control js-bootstrap-datetime" type="text" name="post[published_time]"
                                   value="<?php echo date('Y-m-d H:i:s',time()); ?>">
                        </td>
                    </tr>
                </table>

                <div class="form-group">
                    <audio class="mpp3" style="display: none;" controls="controls">
                        <source src="__TMPL__/public/6480.mp3"/>
                    </audio>
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" style="width: 10vw;" class="btn btn-success subb">确认提交</button>
                    </div>
                </div>
                <script>
                    $('.subb').click(function () {
                        //获取分类信息
                        var cate = $("#cate  option:selected").val();
                        //获取名称
                        var name = $('.name').val();
                        //获取价格
                        var price = $('#price').val();
                        //获取销量
                        var sales = $('#sales').val();
                        //获取封面图
                        var thumbbb = $('.thumbb').val();
                        //获取详细内容
                        var des = UE.getEditor( 'content' ).getContent();
                        //判断是否选中
                        var check = $('.checkk').is(':checked');
                        //是否为推荐
                        if(check == 1){
                            check = 1;
                        }else {
                            check = 0;
                        }
                        $.ajax({
                            url:'/mainiu/goods/add',
                            type:"post",
                            data:{
                                cate:cate,
                                name:name,
                                price:price,
                                sales:sales,
                                thumb:thumbbb,
                                des:des,
                                ishot:check
                            },
                            success:function(data){
                                var ress= $.parseJSON(data);
                                if(ress.sta==1){
                                    $('.mpp3')[0].play();
                                    alert('提交成功');
                                    location.reload()
                                }else {
                                    alert(ress)
                                }
                            },
                            error:function(e){
                                alert('失败');
                            }
                        });
                    });
                </script>
            </div>
        </div>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });
</script>
</body>
</html>
